package com.zhuannimei.view;

import com.zhuannimei.R;
import com.zhuannimei.fragment.BaseFragment;
import com.zhuannimei.ui.BaseActivity;

import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * 
 * @author xxhong
 * 
 */
public class TitlePane {
	BaseActivity mActivity;
	public TitlePane(BaseFragment fragment) {
	}
	public TitlePane(BaseActivity activity) {
		this.mActivity = activity;
	}
	public Button getLeftButton() {
		return (Button) mActivity.findViewById(R.id.ii_title_left);
	}

	public Button getRightButton() {
		return (Button) mActivity.findViewById(R.id.ii_title_right);
	}

	public void setTitle(String title) {
		TextView tv = (TextView) mActivity.findViewById(R.id.ii_title_context);
		tv.setText(title);
	}

	public void setTitle(int title) {
		TextView tv = (TextView) mActivity.findViewById(R.id.ii_title_context);
		tv.setText(title);
	}

	public void setLeftButtonText(String text) {
		Button leftButton = (Button) mActivity.findViewById(R.id.ii_title_left);
		leftButton.setText(text);
	}
	/**
	 * 返回titleBar
	 * @return
	 */
	public RelativeLayout getjTitleBar(){
		return (RelativeLayout) mActivity.findViewById(R.id.ii_common_title);
	}

	/**
	 * 给左边按钮 设置文字 和点击事件
	 * 
	 * @param text
	 * @param listener
	 */
	public void setLeftButtonTextAndListener(String text,
			View.OnClickListener listener) {
		Button leftButton = (Button) mActivity.findViewById(R.id.ii_title_left);
		leftButton.setText(text);
		leftButton.setOnClickListener(listener);
	}

	/**
	 * 给右边按钮 设置文字 和点击事件
	 * 
	 * @param text
	 * @param listener
	 */
	public void setRightButtonTextAndListener(String text,
			View.OnClickListener listener) {
		Button rightButton = (Button) mActivity.findViewById(R.id.ii_title_right);
		rightButton.setText(text);
		rightButton.setOnClickListener(listener);
	}
}
